package com.lxl.hadoop.order;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Author lixilin
 * @Date 2022/1/1 10:06
 * @Description
 */
public class OrderMapper extends Mapper<LongWritable, Text,OrderBean, NullWritable> {
    OrderBean orderBean = new OrderBean();
    NullWritable nullWritable = NullWritable.get();
    protected void map(LongWritable key, Text value,
                       Context context) throws IOException, InterruptedException {
        //0000001	Pdt_01	222.8
        String line = value.toString();
        String[] words = line.split("\t");
        this.orderBean.setOrderCode(Integer.parseInt(words[0]));
        this.orderBean.setMoney(Double.parseDouble(words[2]));
        context.write(this.orderBean,nullWritable);
    }
}
